import { request } from '../utils/request';
import type { ApiResponse } from '../types/common';
import type { ReportListParams, ReportItem, ReportDetail } from '../types/report';

// 旧的接口，页面上无用

// API 请求方法
export const reportApi = {
  // 获取报告列表
  getReportList: (params: ReportListParams) => {
    return request.get<any, ApiResponse<{ count: number; results: ReportItem[] }>>('/industry/', {
      params,
    });
  },

  // 获取报告详情
  getReportDetail: (reportId: string) => {
    return request.get<any, ApiResponse<ReportDetail>>(`/industry/${reportId}/`);
  },

  // 创建报告
  createReport: (data: Partial<ReportDetail>) => {
    return request.post<any, ApiResponse<{ reportId: string }>>('/industry/', data);
  },

  // 更新报告
  updateReport: (reportId: string, data: Partial<ReportDetail>) => {
    return request.put<any, ApiResponse<null>>(`/industry/${reportId}/`, data);
  },

  // 删除报告
  deleteReport: (reportId: string) => {
    return request.delete<any, ApiResponse<null>>(`/industry/${reportId}/`);
  },

  // 导出报告
  exportReport: (reportId: string, data: {
    format: 'pdf' | 'word' | 'html';
    template?: string;
    options?: {
      includeAttachments?: boolean;
      includeReferences?: boolean;
    }
  }) => {
    return request.post<any, ApiResponse<{ url: string }>>(`/industry-report/${reportId}/export`, data);
  }
};